#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	int a,b,c,d=0,e,f;
	scanf("%d %d %d",&a,&b,&c);
	for(int i=c;i>=b;i--){
		d=max(d,i%a);
		if(d==a-1)break;
	} printf("%d",d);
	return 0;
} 
